/*
 * @(#)ResultProcess.java
 * 
 * Project: CUPSecureBM
 * 
 * Modify Information:
 * =============================================================================
 * Author           Date              Description 
 * hitrust          2005-12-7         first release
 * 
 * Copyright Notice:
 * =============================================================================
 * Copyright (c) 2001-2005 Beijing HiTRUST Technology Co., Ltd. 1808 Room,
 * Science & Technology Building, No. 9 South Street, Zhong Guan Cun, Haidian
 * District, Beijing ,100081, China All rights reserved.
 * 
 * This software is the confidential and proprietary information of Beijing
 * HiTRUST Technology Co., Ltd. ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in accordance
 * with the terms of the license agreement you entered into with HiTRUST.
 * 
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.util.page;
import javax.servlet.*;

public class ParamUtil {
    /**
     * 获得request中指定名称的参数值,若有中文乱码问题请增加转码部分
     * @param request ServletRequest对象
     * @param paramName 参数名称
     * @return 如果该变量值存在则返回该值，否则返回""
     */
    public static String getParameter( ServletRequest request, String paramName ) {
        String temp = request.getParameter(paramName);
        if (temp != null && !temp.equals("")) {
            //若有中文问题，请将下面语句注释
            try {
               // temp = new String(temp.getBytes("8859_1"), "GB2312");
            }
            catch (Exception e) {
                return "";
            }
            return temp;
        }
        else {
            return "";
        }
    }

    /**
     * 获得request中的int型参数值
     * @param request ServletRequest对象
     * @param paramName 参数名称
     * @param defaultNum 默认值，如果没有返回该值
     * @return 如果该参数值存在则返回其转换为int型的值，否则返回defaultNum
     */
    public static int getIntParameter( ServletRequest request, String paramName, int defaultNum ) {
        String temp = request.getParameter(paramName);
        if (temp != null && !temp.equals("")) {
            int num = defaultNum;
            try {
                num = Integer.parseInt(temp);
            }
            catch (Exception ignored) {
            }
            return num;
        }
        else {
            return defaultNum;
        }
    }
  }///////////



